﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace _0712502_0712504_DesignPatternGame
{
    /// <summary>
    /// Nha may chua san cac mẫu Body cua tank
    /// </summary>
    public class TankBodyFactory : GameObjectFactory
    {       
        public override void InitPrototypes()
        {
            _nprototype = 7;
            _prototypes = new TankBodyModel[_nprototype];

            _prototypes[(int)IDTank.idPlayerTankLevel1] = new TankBodyModel(IDTankbody.idPlayerTankLevel1, 200,20); //Player Tank Lv1 Body
            _prototypes[(int)IDTank.idPlayerTankLevel1].InitModel(GameResourceContainer.ImageManager.PlayerTankBody, new Rectangle(0, 0, 54, 54), new Vector2(27,27));
            _prototypes[(int)IDTank.idPlayerTankLevel1].SpriteModel.itexture2d = 0;
            
            _prototypes[(int)IDTank.idPlayerTankLevel2] = new TankBodyModel(IDTankbody.idPlayerTankLevel2, 200,30); //Player Tank Lv2 Body
            _prototypes[(int)IDTank.idPlayerTankLevel2].InitModel(GameResourceContainer.ImageManager.PlayerTankBody, new Rectangle(0, 0, 54, 54), new Vector2(27, 27));
            _prototypes[(int)IDTank.idPlayerTankLevel2].SpriteModel.itexture2d = 1;

            _prototypes[(int)IDTank.idPlayerTankLevel3] = new TankBodyModel(IDTankbody.idPlayerTankLevel3,200,40); //Player Tank Lv3 Body
            _prototypes[(int)IDTank.idPlayerTankLevel3].InitModel(GameResourceContainer.ImageManager.PlayerTankBody, new Rectangle(0, 0, 54, 54), new Vector2(27, 27));
            _prototypes[(int)IDTank.idPlayerTankLevel3].SpriteModel.itexture2d = 2;

            _prototypes[(int)IDTank.idTank1] = new TankBodyModel(IDTankbody.idTank1,200,20); //Com Tank 1 Body
            _prototypes[(int)IDTank.idTank1].InitModel(GameResourceContainer.ImageManager.ComTankBody, new Rectangle(0, 0, 54, 54), new Vector2(27, 27));
            _prototypes[(int)IDTank.idTank1].SpriteModel.itexture2d = 0;

            _prototypes[(int)IDTank.idTank2] = new TankBodyModel(IDTankbody.idTank2,200,30); //Com Tank 2 Body
            _prototypes[(int)IDTank.idTank2].InitModel(GameResourceContainer.ImageManager.ComTankBody, new Rectangle(0, 0, 54, 54), new Vector2(27, 27));
            _prototypes[(int)IDTank.idTank2].SpriteModel.itexture2d = 1;

            _prototypes[(int)IDTank.idTank3] = new TankBodyModel(IDTankbody.idTank3,200,40); //Com Tank 3 Body
            _prototypes[(int)IDTank.idTank3].InitModel(GameResourceContainer.ImageManager.ComTankBody, new Rectangle(0, 0, 54, 54), new Vector2(27, 27));
            _prototypes[(int)IDTank.idTank3].SpriteModel.itexture2d = 2;

            _prototypes[(int)IDTank.idTank4] = new TankBodyModel(IDTankbody.idTank4,200,30); //Com Tank 4 Body
            _prototypes[(int)IDTank.idTank4].InitModel(GameResourceContainer.ImageManager.ComTankBody, new Rectangle(0, 0, 54, 54), new Vector2(27, 27));
            _prototypes[(int)IDTank.idTank4].SpriteModel.itexture2d = 3;
        }
        public override VisibleGameEntity CreateObject(int idx)
        {
            if ((idx < 0) || (idx >= _nprototype))
            {
                return null;
            }
            return _prototypes[idx].Clone();
        }       
    }
}
